package com.java.comprehensive.design.behavioral_model.Interpreter_pattern;

import lombok.AllArgsConstructor;
import lombok.ToString;

/**
 * 用于封装变量的类
 */
@AllArgsConstructor
public class Variable extends AbstractExpression {

    //声明存储变量名的成员变量
    private String name;

    @Override
    public int interpret(Context context) {
        return context.getVal(this);
    }

    @Override
    public String toString() {
        return name;
    }
}
